﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ATSBLL;

public partial class Calibration_CalibrationDateList : System.Web.UI.Page
{
    private TCalibration cail;

    public Calibration_CalibrationDateList()
    {
        cail = new TCalibration();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
    public void BindTests()
    {
        DateTime dt1 = DateTime.Parse(this.TextBox1.Value.Trim());
        DateTime dt2 = DateTime.Parse(this.TextBox2.Value.Trim());

        this.GridView1.DataSource = cail.GetCalibrationsbyDT(dt1, dt2);

        GridView1.DataBind();
        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            if (GridView1.Rows[i].Cells[7].Text == "Fail")
                GridView1.Rows[i].Cells[7].ForeColor = System.Drawing.Color.Red;
        }
      
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        BindTests();
    }

    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        this.GridView1.PageIndex = e.NewPageIndex;
        BindTests();
    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Session["InstrumentID"] = GridView1.SelectedDataKey["InstrumentID"].ToString();
        Session["RecordTime"] = Convert.ToDateTime(GridView1.SelectedDataKey["RecordTime"]);
        Session["UserID"] = GridView1.SelectedDataKey["UserID"].ToString();
        Session["UserID2"] = GridView1.SelectedDataKey["UserID2"].ToString();
        Session["PCIP"] = GridView1.SelectedDataKey["PCIP"].ToString();
        Session["ValueType"] = GridView1.SelectedDataKey["ValueType"].ToString();
        Session["IsPass"] = GridView1.SelectedDataKey["IsPass"].ToString();

        Response.Redirect("~/Calibration/CalibrationDetails/cailbrationItem.aspx");
    }
}
